Fix bugs #428733 and #433301. Turns out the lockFocus logic was flawed,
authorRichard Hult <richard@imendio.com>
Sat, 5 May 2007 10:19:39 +0000 (10:19 +0000)
committerRichard Hult <rhult@src.gnome.org>
Sat, 5 May 2007 10:19:39 +0000 (10:19 +0000)
007-05-05  Richard Hult  <richard@imendio.com>

* gdk/quartz/gdkdrawable-quartz.c:
(gdk_quartz_drawable_get_context),
(gdk_quartz_drawable_release_context): Fix bugs #428733 and #433301.
Turns out the lockFocus logic was flawed, now we only lock/unlock
when called outside a real expose event and never flush manually.

svn path=/trunk/; revision=17798

ChangeLog
gdk/quartz/gdkdrawable-quartz.c

index 22b57dccd75e2e8595feb9539026405f83f6c9c0..412b7b5e78996c103a181eba9fc79b94f2d0d29c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-05  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkdrawable-quartz.c:
+       (gdk_quartz_drawable_get_context),
+       (gdk_quartz_drawable_release_context): Fix bugs #428733 and #433301.
+       Turns out the lockFocus logic was flawed, now we only lock/unlock 
+       when called outside a real expose event and never flush manually.
+
 2007-05-03  Behdad Esfahbod  <behdad@gnome.org>
 
        * gtk/gtklabel.c (gtk_label_ensure_layout):
index 3b60a9ce09c1f97a7634fc6041b7f8b8ad22fb54..113bee4d674a3913aac40abe74f586f9f3f5d5bf 100644 (file)
@@ -600,22 +600,23 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable,
                                 gboolean     antialias)
 {
   GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
+  CGContextRef           cg_context;
 
   if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable) &&
       GDK_WINDOW_DESTROYED (drawable_impl->wrapper))
     return NULL;
 
-  CGContextRef cg_context;
-  
   if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
     {
       GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
-         
-      /* Lock focus when not called as part of begin/end paint cycle. 
-       * This is needed to allow broken apps that draw outside of expose
-       * to still work (somewhat). 
+
+      /* Lock focus when not called as part of a drawRect call. This
+       * is needed when called from outside "real" expose events, for
+       * example for synthesized expose events when realizing windows
+       * and for widgets that send fake expose events like the arrow
+       * buttons in spinbuttons.
        */
-      if (window_impl->begin_paint_count == 0)
+      if (window_impl->in_paint_rect_count == 0)
        {
          window_impl->pool = [[NSAutoreleasePool alloc] init];
          if (![window_impl->view lockFocusIfCanDraw])
@@ -695,19 +696,16 @@ gdk_quartz_drawable_release_context (GdkDrawable  *drawable,
       CGContextRestoreGState (cg_context);
       CGContextSetAllowsAntialiasing (cg_context, TRUE);
 
-      /* Only flush and unlock if called outside the expose, since it's
-       * already handled for otherwise.
-       */
-      if (window_impl->in_paint_rect_count == 0 && window_impl->begin_paint_count == 0)
+      /* See comment in gdk_quartz_drawable_get_context(). */
+      if (window_impl->in_paint_rect_count == 0)
        {
-         CGContextFlush (cg_context);
          [window_impl->view unlockFocus];
-       }
 
-      if (window_impl->pool)
-       {
-         [window_impl->pool release];
-         window_impl->pool = NULL;
+         if (window_impl->pool)
+           {
+             [window_impl->pool release];
+             window_impl->pool = NULL;
+           }
        }
     }
   else if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))